//
//  StatzSourceTokenCell.m
//  Statz
//
//  Created by Dave MacLachlan on 07/07/25.
//
// Copyright 2007 Google Inc.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License.  You may obtain a copy
// of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
// License for the specific language governing permissions and limitations under
// the License.
//

#import "StatzSourceTokenCell.h"
#import "NSBezierPath+RoundRect.h"

@implementation StatzSourceTokenCell
- (NSDictionary*)attributes {
  return [NSDictionary dictionaryWithObjectsAndKeys:
    [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName,
    nil];
}

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)aView {
  cellFrame = NSInsetRect(cellFrame, 2, 0);
  cellFrame = NSOffsetRect(cellFrame, 0, 2);
  NSBezierPath *path = [NSBezierPath bezierPathWithRoundRect:cellFrame cornerRadius:6];
  [[NSColor colorWithDeviceRed:0.8706f green:0.9059f blue:0.9725f alpha:0.5f] set];
  [path fill];
  [[NSColor colorWithDeviceRed:0.6431f green:0.7412f blue:0.9255f alpha:0.75f] set];
  [path stroke];
  cellFrame.origin.x += 4;
  cellFrame.size.width -= 4;
  cellFrame = NSOffsetRect(cellFrame,0, -1);
  [[self stringValue] drawInRect:cellFrame withAttributes:[self attributes]];
}

- (NSSize)cellSize {
  NSSize size = [[self stringValue] sizeWithAttributes:[self attributes]];
  size.width +=14;
  size.height -=1;
  return size;
}
  
@end
